import { _decorator, Animation, AudioSource, Component, director, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('SettingManager')
export class SettingManager extends Component {
    @property({type: Node, tooltip: "设置面板"})
    private settingPanel: Node | null = null;
    @property({type: Node, tooltip: "是否确认退出到菜单面板"})
    private ifSureToBack: Node | null = null;
    start() {
        this.initSettingPanel()
    }

    update(deltaTime: number) {
        
    }

    //初始化按钮面板状态
    initSettingPanel() {
        this.settingPanel.active = false;
        this.ifSureToBack.active = false;
    }
    //点击设置按钮
    onClickSettingBtn(event: Event) {
        console.log(6)
        this.settingPanel.active = true;
        let p = this.settingPanel.getChildByName("BG_Setting").getComponent(Animation).play();
        event.target.getComponent(AudioSource).play();
    }
    //点击返回按钮
    onClickBackBtn() {
        this.ifSureToBack.active = true;
        this.ifSureToBack.getComponent(Animation).play();
    }
    //点击确定按钮
    onClickSureBtn() {
        this.ifSureToBack.active = false;
        this.settingPanel.active = false;
        director.loadScene("MenuScene")
    }
    //点击取消按钮
    onClickCancelBtn() {
        this.ifSureToBack.active = false;
    }
    //关闭设置界面
    closeSettingPanel() {
        this.settingPanel.active = false;
    }
}


